-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTime.cs
43 lines (37 loc) · 1.09 KB
/
Time.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
namespace My
{
using System;
using System.Threading;
/// <summary>
/// 时间管理、转换相关函数
/// </summary>
/// <remarks></remarks>
public sealed partial class Time
{
/// <summary>
/// 将当前线程挂起指定的时间(System.Threading.Thread.Sleep)
/// </summary>
/// <param name="Millisecond">等待时间(单位毫秒,必须为非负值)</param>
/// <remarks></remarks>
public static void Wait(uint Millisecond)
{
if (Millisecond > 0)
{
try
{
Thread.Sleep((int)Millisecond);
}
catch (Exception ex) { }
}
}
/// <summary>
/// 获取UNIX时间戳
/// </summary>
/// <returns>UNIX时间戳整数</returns>
/// <remarks></remarks>
public static uint Stamp()
{
return (uint)Math.Round(((TimeSpan)(DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0))).TotalSeconds);
}
}
}